package com.mybed.crm.controller;

import com.mybed.crm.pojo.dto.PageDeptDto;
import com.mybed.crm.pojo.dto.PageReportChannelDto;
import com.mybed.crm.pojo.dto.PageReportCluesDto;
import com.mybed.crm.pojo.dto.PageReportContractDto;
import com.mybed.crm.pojo.vo.LineChartVo;
import com.mybed.crm.pojo.vo.VulnerabilityMapVo;
import com.mybed.crm.result.PageResult;
import com.mybed.crm.result.Result;
import com.mybed.crm.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Slf4j
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    //客户统计
    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo contractStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return reportService.contractStatistics(beginCreateTime, endCreateTime);
    }


    /**
     * 客户统计的分页查询
     * @return
     */
    @GetMapping("/contractStatisticsList")
    public PageResult queryPageContract(PageReportContractDto pageReportContractDto){
        PageResult pageResult = reportService.queryPageContract(pageReportContractDto);
        return pageResult;
    }

    //销售统计
    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo salesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return reportService.salesStatistics(beginCreateTime, endCreateTime);
    }

    /**
     * 销售统计的分页查询
     * @param beginCreateTime
     * @param endCreateTime
     * @param pageDeptDto
     * @return
     */
    @GetMapping("/deptStatisticsList/{beginCreateTime}/{endCreateTime}")
    public PageResult queryPageDept(@PathVariable LocalDate beginCreateTime, @PathVariable LocalDate endCreateTime , PageDeptDto pageDeptDto){
        PageResult pageResult = reportService.queryPageDept(beginCreateTime,endCreateTime,pageDeptDto);
       return pageResult;
    }

  /**
     * 线索统计的分页查询
     * @param pageReportCluesDto
     * @return
     */
    @GetMapping("/cluesStatisticsList")
    public PageResult queryPageClue(PageReportCluesDto pageReportCluesDto){
        PageResult pageResult = reportService.queryPageClue(pageReportCluesDto);
        return pageResult;
    }


    //线索管理
    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo cluesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.cluesStatistics(beginCreateTime, endCreateTime);
    }

   /* //客户统计
    @GetMapping("/cluesStatisticsList/{beginCreateTime}/{endCreateTime}")
    public LineChartVo cluesStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.cluesStatisticsList(beginCreateTime,endCreateTime);
    }*/


    //渠道统计 饼图1
    @GetMapping("/chanelStatistics/{beginCreateTime}/{endCreateTime}")
    public Result chanelStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return Result.success(reportService.chanelStatistics(beginCreateTime, endCreateTime));
    }

    /**
     * 渠道统计的分页查询
     * @param pageReportChannelDto
     * @return
     */
    @GetMapping("/activityStatisticsList")
    public PageResult queryPageActivity(PageReportChannelDto pageReportChannelDto){
        PageResult pageResult = reportService.queryPageActivity(pageReportChannelDto);
        return pageResult;
    }

    //活动统计 饼图2
    @GetMapping("/activityStatistics/{beginCreateTime}/{endCreateTime}")
    public Result activityStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return Result.success(reportService.activityStatistics(beginCreateTime, endCreateTime));
    }

    //漏斗统计
    @GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public Result<VulnerabilityMapVo> getVulnerabilityMap(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        return Result.success(reportService.getVulnerabilityMap(beginCreateTime, endCreateTime));
    }

}
